<template>
    <basic-container>
        <!--表单-->
        <div style="width:50%;margin-top: 10px;">
            <avue-form ref="form" v-model="obj" :option="option"  @submit="submit">
            </avue-form>
        </div>

    </basic-container>
</template>
<script>
    import {
        setJyt,
        getJyt
    } from "../../api/base/sysSet/jwtSet";
    import {
        convertAddCode
    } from '@/util/util';

    export default {
        data() {
            return {
                obj:{},
                option:{
                    emptyBtn:false,
                    labelWidth:'200',
                    labelPosition:'left',
                    column: [{
                        label: "jwt 秘钥",
                        prop: "jwtSecret",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入jwt 秘钥",
                            trigger: "blur"
                        }]
                    },{
                        label: "Access Token 超时时间(秒)",
                        prop: "jwtATExpiredDate",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入Access Token超时时间",
                            trigger: "blur"
                        }]
                    },{
                        label: "Refresh Token 超时时间(秒)",
                        prop: "jwtRTExpiredDate",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "请输入Refresh Token超时时间",
                            trigger: "blur"
                        }]

                    }]
                }
            }
        },
        created(){
            this.getData()
        },
        methods:{
            getData(){
               getJyt().then(res=>{
                   if(res.data.code==200){
                       this.obj=res.data.data
                   }
               })
            },
            submit (form,done) {
                convertAddCode(this.obj.jwtSecret,data=>{
                    this.obj.jwtSecret = data;
                });
                setJyt(this.obj).then(()=>{
                    done()
                        this.$message({
                            message:'提交成功',
                            type:'success'
                        })
                        this.getData()
                })
            },
        }
    }

</script>